home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Maestro / Scripts / installPgmr < prev    next >
Encoding:
Text File  |  1996-01-15  |  7.3 KB  |  186 lines

  1. #!/bin/csh -f
  2. # Installation script for MAEstro programmer libraries.
  3. # Copyright (C) 1994 by George D. Drapeau
  4. #
  5.  
  6. set OsRelease = `uname -r`                    # What release of the operating system is this?
  7. switch ($OsRelease)
  8.   case "4.*":                            # SunOS 4.X
  9.     set RootDir = /cdrom/MAEstro/lib            # Set top-level directory from which to retrieve MAEstro libraries
  10.     set RootIncludeDir = /cdrom/MAEstro/include        # This is where MAEstro include files are
  11.     set SourceDir = /cdrom/MAEstro/SamplePrograms        # Indicate where sample source code can be found
  12.   breaksw
  13.   case "5.*":                            # SunOS 5.X
  14.     set RootDir = /cdrom/unnamed_cdrom/MAEstro/lib        # Set top-level directory from which to retrieve MAEstro libraries
  15.     set RootIncludeDir = /cdrom/unnamed_cdrom/MAEstro/include# This is where MAEstro include files are
  16.     set SourceDir = /cdrom/unnamed_cdrom/MAEstro/SamplePrograms# Indicate where sample source code can be found
  17.   breaksw
  18.   default:                            # Probably not any SunOS
  19.     set RootDir = /cdrom/MAEstro/lib            # Set top-level directory from which to retrieve MAEstro libraries
  20.     set RootIncludeDir = /cdrom/MAEstro/include        # This is where MAEstro include files are
  21.     set SourceDir = /cdrom/MAEstro/SamplePrograms        # Indicate where sample source code can be found
  22.   breaksw
  23. endsw    
  24.  
  25. set DestDir = "/usr/local/MAEstro"                # Set up a default directory for the MAEstro libraries
  26. set OsType = `uname -s`                        # Determine the operating system type
  27.  
  28. if ($OsType != "SunOS") then                    # Is this a Sun workstation?  If not, exit now
  29.   echo "This operating system is not SunOS.  Please install from a Sun workstation."
  30.   exit (-1)
  31. endif
  32.  
  33. set OsRelease = `uname -r`                    # What release of the operating system is this?
  34. switch ($OsRelease)
  35.   case "4.*":                            # SunOS 4.X
  36.     echo "Installing MAEstro programmer libraries for SunOS 4.X."
  37.     set OsDir = "SunOS4"
  38.   breaksw
  39.   case "5.*":                            # SunOS 5.X
  40.     echo "Installing MAEstro programmer libraries for Solaris 2.X."
  41.     set OsDir = "Solaris2"
  42.   breaksw
  43.   default:                            # Probably not any SunOS
  44.     echo "You are using either an unknown version of SunOS or are installing"
  45.     echo "from a non-Sun workstation.  Please install from a Sun workstation"
  46.     echo "for the installation to work correctly."
  47.     exit (-1)
  48.   breaksw
  49. endsw    
  50.  
  51. set MAEstroLibDir = "$RootDir/$OsDir"                # Determine where to find the correct MAEstro libraries
  52.  
  53. if (!(-e $MAEstroLibDir)) then
  54.         echo "Cannot find the directory $RootDir.  Please make sure"
  55.     echo "that you have mounted the CD-ROM as /cdrom, then try"
  56.     echo "this installation script again."
  57.         exit (-1)
  58. endif
  59.  
  60. set DiskSpaceNeeded = `du -s $MAEstroLibDir | awk '{print $1}'`    # Determine disk space needed to install the MAEstro libraries
  61.  
  62. echo ""
  63. echo "The default installation directory is "
  64. echo "    $DestDir"
  65. echo ""
  66. echo "The MAEstro libraries require $DiskSpaceNeeded KB of disk space."
  67. echo ""
  68. echo "Would you like to install the MAEstro libraries into "
  69. echo -n "'$DestDir'? [y/n] "
  70. set DestDir_ok = $<                        # Ask the installer if the default directory is okay.
  71.  
  72.  
  73. CustomInstallDirectory:                        # Here begins code to install apps in a custom directory
  74.  
  75. if ($DestDir_ok != y) then                    # The default directory is not okay, prompt for a new place
  76.     echo ""
  77.         echo "Where would you like to install the MAEstro libraries? "
  78.     echo "(type 'q' to quit the installation process now.)"
  79.     echo -n "--> "
  80.         set DestDir = $<
  81. endif
  82.  
  83. if ($DestDir == "q") then                    # Did the installer choose to exit without installing the software?
  84.   echo "MAEstro programmer libraries were not installed."
  85.   exit (-1)                            # Yes, honor that choice and quit right now
  86. endif
  87.  
  88. if (!(-e $DestDir)) then                    # Does the specified directory exist?
  89.   echo ""
  90.   echo "The directory '$DestDir' does not exist."
  91.   echo -n "Would you like to create it? [y/n] "            # No, shall this program create such a directory?
  92.   set create = $<
  93.   if ($create == y) then                    # Yes, try to create the directory specified by the installer
  94.           echo  -n "Creating installation directory..."
  95.       mkdir $DestDir >& /dev/null                # Create the directory and set appropriate permissions
  96.       if ($status != 0) then
  97.         echo ""
  98.         echo "Could not create the directory $DestDir."
  99.         echo "Please try another directory name."
  100.         echo ""
  101.         goto CustomInstallDirectory
  102.       endif
  103.       chmod 0755 $DestDir
  104.           echo "Done."
  105.   else
  106.           echo "Please try again:"
  107.       echo ""
  108.       goto CustomInstallDirectory
  109.   endif
  110. else
  111.   echo ""
  112. endif
  113.  
  114. if (!(-e $DestDir/lib)) then                    # Does the "lib" directory exist?
  115.   mkdir $DestDir/lib >& /dev/null                # No, try to create it
  116.   if ($status != 0) then                    # Did the creation fail?
  117.     echo ""                            # Yes, report the error and exit without doing anything more
  118.     echo "Could not create the directory $DestDir/lib."
  119.     echo "Please make sure you have permission to create directories under"
  120.     echo "$DestDir then run this installation script again."
  121.     exit (-1)
  122.   endif
  123. endif
  124.  
  125. if (!(-e $DestDir/include)) then                # Does the "include" directory exist?
  126.   mkdir $DestDir/include >& /dev/null                # No, try to create it
  127.   if ($status != 0) then                    # Did the creation fail?
  128.     echo ""                            # Yes, report the error and exit without doing anything more
  129.     echo "Could not create the directory $DestDir/include."
  130.     echo "Please make sure you have permission to create directories under"
  131.     echo "$DestDir then run this installation script again."
  132.     exit (-1)
  133.   endif
  134. endif
  135.  
  136. if (!(-e $DestDir/Source)) then                    # Does the "Source" directory exist?
  137.   mkdir $DestDir/Source >& /dev/null                # No, try to create it
  138.   if ($status != 0) then                    # Did the creation fail?
  139.     echo ""                            # Yes, report the error and exit without doing anything more
  140.     echo "Could not create the directory $DestDir/Source."
  141.     echo "Please make sure you have permission to create directories under"
  142.     echo "$DestDir then run this installation script again."
  143.     exit (-1)
  144.   endif
  145. endif
  146.  
  147.  
  148. #
  149. # Avoid problems with long df entries...
  150. #
  151. set DF_LONG = `df $DestDir | tail -1 | awk '{print $4}' | egrep % | wc -c`
  152. if ( $DF_LONG == "0" ) then 
  153.         set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $4}'`
  154. else
  155.         set FreeDiskSpace = `df $DestDir | tail -1 | awk '{print $3}'`
  156. endif
  157.  
  158. if ($FreeDiskSpace < $DiskSpaceNeeded) then            # Is there enough space to hold the MAEstro apps?
  159.   echo "Sorry, the MAEstro programmer libraries require $DiskSpaceNeeded KB of free disk space"    # No, inform the installer
  160.   echo "but there are only $FreeDiskSpace KB free in '$DestDir'."
  161.   echo "Please free up disk space or install MAEstro programmer libraries"
  162.   echo "in a different directory, then run this installation script again."
  163.   exit (-1)                            # Exit this script without doing any installation
  164. endif
  165.  
  166.  
  167. echo ""
  168. echo -n "Installing MAEstro programmer libraries into '$DestDir'..."
  169.  
  170. cp $MAEstroLibDir/* $DestDir/lib                # Copy the MAEstro libraries into the desired directory
  171. if ($OsDir == "SunOS4") then                    # Does "ranlib" need to be run on the installed libraries?
  172.   pushd $DestDir/lib >& /dev/null                # Yes, go to the installed directory and run "ranlib" for...
  173.   ranlib *.a                            # ...each installed library.
  174.   popd >& /dev/null
  175. endif
  176.  
  177. cp $RootIncludeDir/* $DestDir/include >& /dev/null        # Copy the MAEstro include files into the desired directory
  178. cp -r $SourceDir $DestDir/Source >& /dev/null            # Copy the MAEstro sample programs into the desired directory
  179.  
  180. echo "Done."
  181.  
  182. echo ""
  183. echo 'Installation was successful.  Enjoy\!'
  184.  
  185. exit (0)                            # Installation was successful; get outtahere.
  186.